package com.example.dept.service;

import com.example.api.model.Dept;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @ClassName: DeptClientServiceFallbackFactory
 * @Author: liugui
 * @Date: 2020-09-19 15:16
 **/
@Component
public class DeptClientServiceFallbackFactory implements FallbackFactory<DeptClient> {

    @Override
    public DeptClient create(Throwable throwable) {
        return new DeptClient() {
            @Override
            public Dept get(long id) {
                return new Dept().setDeptno(id).setDname("该ID：" + id + "此刻服务已经关闭,服务降级")
                        .setDb_source("no this database in MySQL");
            }

            @Override
            public List<Dept> list() {
                return null;
            }

            @Override
            public boolean add(Dept dept) {
                return false;
            }
        };
    }
}
